﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WindowsFormsApplication1;

namespace RoleSelection
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

        private void Login_Load(object sender, EventArgs e)
        {
            this.webBrowser1.Navigate(@"https://xui.ptlogin2.qq.com/cgi-bin/xlogin?proxy_url=http://game.qq.com/comm-htdocs/milo/proxy.html&appid=21000501&target=top&s_url=http%3A%2F%2Fqqhx.qq.com%2Fcp%2Fa20140515hxglxt%2Fpage02.shtml&style=20&daid=8");
        }

        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            using (StreamReader sr = new StreamReader(webBrowser1.DocumentStream, Encoding.GetEncoding(("gbk"))))
            {
                string strhtml = sr.ReadToEnd();
                //todo 这样判断虽然不太靠谱，但最方便
                if (strhtml.Contains("角色改名"))
                {
                    this.webBrowser1.ScriptErrorsSuppressed = true;
                    this.webBrowser1.Navigate(@"http://minigame.qq.com/gameforum/index.html?appid=10358");
                    this.Hide();
                    Form1.IsLogin = true;
                }
            }
                
           
           
        }
    }
}
